A good answer might be:

Applets are not stand-alone objects, and only run in the context of a larger program (such as a browser.)


Running an Applet

To run an applet, you need a Web page that includes it. A Web page is a text file that can be displayed by a Web browser. Here is a tiny Web page that asks for the applet AnotherHello:

<html>
<body>
<applet code="AnotherHello.class" width="300" height="150">
</applet>
</body>
</html>

This tells the browser to run the applet AnotherHello.class, and to use an area of the screen 300 pixels wide and 150 high. To create this tiny Web page, type the above characters into NotePad (or copy and paste them into NotePad). Then save the file as AnotherHello.html in the same directory that has AnotherHello.class. At this point your directory should look something like this:

C:\> dir A*.*

03/07/98  08:01p                   560 AnotherHello.class
03/07/98  08:01p                   199 AnotherHello.html
03/07/98  08:00p                   247 AnotherHello.java
               3 File(s)         1,006 bytes
                           157,295,104 bytes free

Now you can use your Web browser to look at AnotherHello.html. Find the file with your file browser and double click on it. Your default Web browser should start running and should display the applet. Or you can use the appletviewer:

C:\> appletviewer AnotherHello.html

Sometimes browsers are not set up for applets, or have other problems. The appletviewer is in the same directory as java and javac and is more reliable for viewing your applets than a Web brower. However, the appletviewer shows you only the applet part of an HTML file. The other parts (if any) are omitted.

QUESTION 8:

Fill in the blanks in the following HTML file so that it asks to run the applet AEHousman in a window that is 250 pixels wide and 200 pixels high.

<html>
<body>
<applet code="_______________"  width=_____ height=_____>
</applet>
</body>
</html>